from db.dbUtils import MysqlPool


def get_at_department_by_f_id_and_week_and_day(f_id, week, day):
    with MysqlPool() as pool:
        c = pool.cursor
        sql = "select * from se_at_department where department_id={} and week={} and day={}".format(f_id, week, day)
        c.execute(sql)
        return c.fetchall()


def insert_into_department_call(sql):
    with MysqlPool() as pool:
        c = pool.cursor
        try:
            c.execute(sql)
            pool.conn.commit()
            return True
        except Exception as e:
            print(e)
            pool.conn.rollback()
            return False
        return False


def update_department_call(sql):
    with MysqlPool() as pool:
        c = pool.cursor
        try:
            c.execute(sql)
            pool.conn.commit()
            return True
        except Exception as e:
            print(e)
            pool.conn.rollback()
            return False
        return False


def fix_record_department(sql):
    with MysqlPool() as pool:
        c = pool.cursor
        try:
            c.execute(sql)
            pool.conn.commit()
        except Exception as e:
            print(e)